C# GenericHost changes to facilitate better Accept header support, DateOnly parsing, multitargetting, exposing more headers and proper JIT tokens #22062
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Quite some small changes in this PR, felt like a waste to split them up. Commit
f814598
could be expanded to include even more versions of .NET if so desired.8a7edb2 - Update documentation and samples
0bfc7f8 - Support multi targetting
This makes it so that when you have both net8 and net9 (for example) the csproj includes both. This makes sure that consumers of your package will get to use the newest transitive dependencies.
c3b74e5 - Expose ContentHeaders on ApiResponse, to access ContentDisposition for example with file downloads.
Very useful for downloading files, you can now access details and many more headers about the actual Content.
f35af99 - Include full response object in ApiException
This gives adds a lot of convenience to debugging using a generated API client.
c56afb2 - Add support for other Accept header values or full arrays when multiple options are present.
This uses the correct (array) for the Accept header for non json responses.
a98c339 - Make TokenProvider not contain state so subclassing actually works correctly with JIT requested tokens (for long lived ApiClients)
This allows the ApiClient to use say client credentials and an OAuth flow to requests and cache tokens appropriately without knowing the tokens before hand.
Example implementation
74ab0ef - Fix DateOnly parsing, DateTimeStyles are not supported in TryParseExact
This fixes the calls to TryParseExact so they actually work, the DateTimeStyles besides None are not supported when say parsing the string "2025-07-01" which is absolutely in the given formats array. (It hits this case)
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)"fixes #123"
present in the PR description)C# Technical Committee
@mandrean @shibayan @Blackclaws @lucamazzanti @iBicha
@devhl-labs
The generator seems to still support the netstandard1.* targets but none of the dependencies still list those on Nuget. Seems like they are fully abandoned/deprecated.
And has generichost ever supported .NET4.7 and .NET4.8? Seems like System.Text.Json is missing regardless of the changes in this PR.